package com.zhaocheng.tank;

import java.awt.*;

/**
 * @author zhaocheng
 * @version 1.0
 * @date 2020/6/21 0021 19:20
 */
public class Explode {

    public static final int WIDTH = ResourceManage.explodes[0].getWidth();
    public static final int HIGHT = ResourceManage.explodes[0].getHeight();

    private int x, y;
    private int step = 0;
    private TankFrame tankFrame;

    public Explode(int x, int y,TankFrame tankFrame) {
        this.x = x;
        this.y = y;
        this.tankFrame = tankFrame;

        new Thread(() -> new Audio("audio/explode.wav").play()).start();
    }

    public void paint(Graphics g) {
        g.drawImage(ResourceManage.explodes[step++],x,y,null);
        if (step >= ResourceManage.explodes.length){
            tankFrame.explodes.remove(this);
        }
    }

}
